import { createApp } from 'vue'
import App from '@/App.vue'
import router from '@/router'
import store from './store'
import { Swiper, SwiperSlide } from 'swiper/vue'
import SwiperCore, { Autoplay, Pagination } from 'swiper'
import 'virtual:windi.css'
// import 'virtual:svg-icons-register'
import 'swiper/css'
import 'swiper/css/pagination'
import VConsole from 'vconsole'
import { getRouteQuery } from '@/utils'
import useTap from './hooks/useTap'

const query: any = getRouteQuery()

if (Reflect.has(query, 'debug')) {
  new VConsole()
}

SwiperCore.use([Autoplay, Pagination])

let app: LooseObject

function render() {
  app = createApp(App as LooseObject)
  app.use(router)
  app.use(store)
  // eslint-disable-next-line vue/multi-word-component-names
  app.component('Swiper', Swiper)
  app.component('SwiperSlide', SwiperSlide)
  app.directive('tap', useTap())
  app.mount('#app')
  sessionStorage.setItem('originUrlRef', location.href)
}
render()
